class Solution {
public:
    
    double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
        int i = 0, j = 0;
        vector<int> merged;
        while(i < nums1.size() && j < nums2.size())
        {
            if(nums1[i] < nums2[j])
            {
                merged.push_back(nums1[i++]);
            }
            else{
                merged.push_back(nums2[j++]);
            }
        }
        while(i < nums1.size()) merged.push_back(nums1[i++]);
        while(j < nums2.size()) merged.push_back(nums2[j++]);
        int m = merged.size();
        if(m % 2 == 0)
        {
            return (merged[m/2 - 1] + merged[m/2]) / 2.0;
        }
        else
        {
            return merged[m / 2];
        }
    }
};




